package com.hddz.acquisition;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import android.app.Application;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.jb.Preference;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;

import com.hddz.acquisition.barcode.ScanDeviceType;

import org.xutils.x;

public class AcquistionApp extends Application {

    public static final String strKey = "u0GXwW0hE7bAiBTY6pVkaMrz";
    private static final String TAG = null;
    private static AcquistionApp instance;

    private static double distence;
    /**
     * 0:未知 1：正常 2：断开
     */
    private int gpsState = 0;
    private Boolean offline = false;


    @Override
    public void onCreate() {
        // TODO Auto-generated method stub
        super.onCreate();

        x.Ext.init(this);

        instance = this;
        //设置扫描输出模式 1.快速扫描（文本框） 2.模拟键盘 3.广播
        //Preference.setScanOutMode(this, 1);
        //设置支持扫描快捷自定义后缀 默认后缀回车 i -1:无后缀 0：回车 1：分号
        Preference.setScanSuffixModel(this, 0);
        //设置扫描是否支持扫描快捷键 b <code>true</code> 支持 <code>false</code>不支持
        Preference.setScanShortcutSupport(this,true);
        //设置为硬解码
        Preference.setScanDeviceType(this, ScanDeviceType.OneD);
    }


    public static double getDistence() {
        return distence;
    }

    public static AcquistionApp getInstance() {
        return instance;
    }

//    public String getIMEI() {
//        return ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
//    }

//    public String getUniCode() {
//        TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
//        String m_szImei = TelephonyMgr.getDeviceId();
//        String m_szDevIDShort = "35" + Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length()
//                % 10 + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10
//                + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10
//                + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10
//                + Build.USER.length() % 10;
//        String m_szAndroidID = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
//        WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
//        String m_szWLANMAC = wm.getConnectionInfo().getMacAddress();
//        BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter
//        m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
//        String m_szBTMAC = m_BluetoothAdapter.getAddress();
//        String m_szLongID = m_szImei + m_szDevIDShort + m_szAndroidID + m_szWLANMAC + m_szBTMAC;
//        // compute md5
//        MessageDigest m = null;
//        try {
//            m = MessageDigest.getInstance("MD5");
//        } catch (NoSuchAlgorithmException e) {
//            e.printStackTrace();
//        }
//        m.update(m_szLongID.getBytes(), 0, m_szLongID.length());
//        // get md5 bytes
//        byte p_md5Data[] = m.digest();
//        // create a hex string
//        String m_szUniqueID = new String();
//        for (int i = 0; i < p_md5Data.length; i++) {
//            int b = (0xFF & p_md5Data[i]);
//            // if it is a single digit, make sure it have 0 in front (proper
//            // padding)
//            if (b <= 0xF)
//                m_szUniqueID += "0";
//            // add number to string
//            m_szUniqueID += Integer.toHexString(b);
//        } // hex string to uppercase
//        m_szUniqueID = m_szUniqueID.toUpperCase();
//        return m_szUniqueID;
//    }
}
